﻿<Window x:Class="Northwind.UI.WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ViewModel="clr-namespace:Northwind.ViewModel;assembly=Northwind.ViewModel"
        xmlns:AttachedBehaviors="clr-namespace:Northwind.UI.WPF.AttachedBehaviors"
        Title="{Binding Name}" Height="500" Width="700"
        DataContext="{Binding Source={x:Static ViewModel:ViewModelLocator.MainWindowViewModelBaseStatic}}">
    <Window.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsShowOrderWizard}" Value="true">
                    <Setter 
                        Property="AttachedBehaviors:MainWindowAttachedBehaviors.ShowOrderWizard" 
                        Value="true" />
                </DataTrigger>
                <DataTrigger Binding="{Binding IsShowOrderWizard}" Value="false">
                    <Setter 
                        Property="AttachedBehaviors:MainWindowAttachedBehaviors.ShowOrderWizard" 
                        Value="false" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Style>
    <Window.InputBindings>
        <KeyBinding Command="{Binding ShowOrderWizard}" Key="N" Modifiers="Control" />
    </Window.InputBindings>
    <!--<Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                        Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>-->
    <DockPanel>
        <Border DockPanel.Dock="Top" Padding="10" Margin="4"
                CornerRadius="5"
                Background="{StaticResource mainBlueBrush}">
            <TextBlock Text="{Binding Name}"
                    Foreground="White" FontWeight="Bold"
                    FontSize="16" />
            <Border.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="{Binding ShowOrderWizard}" 
                              Header="Order Wizard for New Order" />
                </ContextMenu>
            </Border.ContextMenu>
        </Border>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
        <Expander Padding="10" Margin="4"
                BorderBrush="DarkGray" ExpandDirection="Right" 
                Grid.Row="0" Grid.Column="0"
                IsExpanded="True">
            <Expander.Header>
                <TextBlock Text="{Binding ControlPanel.Name}" FontSize="14"
                        FontWeight="Bold">
                    <TextBlock.LayoutTransform>
                        <RotateTransform Angle="90" />
                    </TextBlock.LayoutTransform>
                </TextBlock>
            </Expander.Header>
            <ContentControl Content="{Binding ControlPanel}" />
        </Expander>
        <TabControl ItemsSource="{Binding Tools}" Margin="4" 
            Grid.Row="0" Grid.Column="1"
            IsSynchronizedWithCurrentItem="True">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <DockPanel Width="120">
                        <Button
                                Command="{Binding Path=CloseCommand}"
                                Content="X" Cursor="Hand"
                                DockPanel.Dock="Right"
                                Focusable="False"
                                FontFamily="Courier"
                                FontSize="9" FontWeight="Bold"
                                Margin="0,1,0,0" Padding="0"
                                VerticalContentAlignment="Bottom"
                                Width="16" Height="16" />
                        <ContentPresenter 
                                Content="{Binding 
                                    Path=ToolTitle}"
                                VerticalAlignment="Center" />
                        
                    </DockPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
        </TabControl>
        </Grid>
    </DockPanel>
</Window>
